<template>
  <div>
    <div id="metadigiee-video-player"></div>
    <button class="openService">开始</button>
  </div>
  <!-- <home :msg="'msg'" /> -->
</template>

<script setup lang="ts">
import home from './view/home/index.vue'
import MetadigieeApi from "metadigiee-api";
const { Service } = MetadigieeApi;
const openServices = async () => {
  let openService = document.querySelector('.openService');
  const params = { host: 'localhost',port:22222,scene:'对应的场景' };
  console.log(openService.checked)
  try {
    // if (openService.checked) {
      let res = await Service.openService(params);
      console.log('=> openService(): ', JSON.stringify(res));
    // } else {
    //   await Service.closeService(params);
    // }
  } catch (error) {
    console.log(error);
  }
}
//添加孪生体
const addTwinModel = async() => { 
  let addTwinModelElement = document.getElementById("addTwinModelId");
  try {
    //添加孪生体
    let params = [
      {
        "modelFiles": {
          "modelId": "1",
          "type": "twinModel",
          "coordType": 1,
          "coord": [
            10,
            10
          ],
          "coordTypeZ": 1,
          "coordZ": 0,
          "rotation": [
            0,
            140,
            0
          ],
          "scale": [
            1,
            1,
            1
          ]
        },
        "modelPrefabName": "VH_Sedan01"
      }
    ];
    let res = await TwinModel.addTwinModel(params);
    console.log('=> addTwinModel(): ', JSON.stringify(res));



    //监听孪生体点击
    res = await Event.addMouseEventListener((event) => {
      addInfoWindow(event);
      console.log('==> MouseModelEventCb():',JSON.stringify(event));
    });
    console.log('=> addMouseEventListener(): ',JSON.stringify(res)});
    //防止再次点击执行
    addTwinModelElement.setAttribute("disabled", true);
  } catch (err) {
    console.log(`底座调用异常:${err}`);
  }
}

setTimeout(() => {
  openServices()
}, 800)





// const { Camera } = MetaDigieeApi
//  try {
//   let params = {
//     "coordType": 1,
//     "coord": [10.675, -14.0196],
//     "coordTypeZ": 1,
//     "coordZ": 0,
//     "pitch": 18,
//     "yaw": 42.5,
//     "armDistance": 120,
//     "flyTime": 0
//   };
//   //设置三维场景中镜头的属性参数
//   let res = await Camera.setCameraInfo(params)
//   returnTextarea.value = JSON.stringify(res)
//   console.log('=> setCameraInfo(): ' + JSON.stringify(res))
// } catch (err) {
//   returnTextarea.value = JSON.stringify(err)
// }
</script>

<style>
body{
  margin: 0;
  padding: 0;
  background: #2d333a;
}
</style>
